import {rand, randAmount, randBoolean, randNumber, randPastDate, randWord} from '@ngneat/falso';
import {format} from 'date-fns';
import CONST from '@src/CONST';
import type {Transaction} from '@src/types/onyx';

export default function createRandomTransaction(index: number): Transaction {
    return {
        amount: randAmount(),
        bank: randWord(),
        cardID: randNumber(),
        cardName: randWord(),
        cardNumber: randWord(),
        billable: randBoolean(),
        category: randWord(),
        comment: {
            comment: randWord(),
            waypoints: {
                [randWord()]: {
                    address: randWord(),
                    lat: index,
                    lng: index,
                    name: randWord(),
                },
            },
            attendees: [{email: randWord(), displayName: 'Test User', avatarUrl: ''}],
        },
        managedCard: randBoolean(),
        created: format(randPastDate(), CONST.DATE.FNS_DB_FORMAT_STRING),
        modifiedCreated: '',
        currency: CONST.CURRENCY.USD,
        modifiedCurrency: '',
        merchant: randWord(),
        modifiedMerchant: randWord(),
        originalAmount: randAmount(),
        originalCurrency: rand(Object.values(CONST.CURRENCY)),
        reportID: index.toString(),
        transactionID: index.toString(),
        tag: randWord(),
        parentTransactionID: index.toString(),
        status: rand(Object.values(CONST.TRANSACTION.STATUS)),
        receipt: {filename: randWord()},
        reimbursable: randBoolean(),
        hasEReceipt: randBoolean(),
        modifiedAmount: 0,
    };
}

const createRandomDistanceRequestTransaction = (index: number): Transaction => {
    return {
        ...createRandomTransaction(index),
        iouRequestType: CONST.IOU.REQUEST_TYPE.DISTANCE,
    };
};

export {createRandomDistanceRequestTransaction};
